package com.cn.hotel.servlet.front;

import com.cn.hotel.model.*;
import com.cn.hotel.service.*;
import com.cn.hotel.service.impl.*;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(value = "/home")
public class HomeServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

//        公司信息获取
        ICompanyInformationService iCompanyInformationService = new CompanyInformationServiceImpl();
        CompanyInformationModel companyInformationModel = iCompanyInformationService.getCompanyInformationModel();
        req.setAttribute("companyInformationModel",companyInformationModel);
        //酒店新闻集合获取
        INewsService iNewsService = new NewsServiceImpl();
        List<NewsModel> newsModelList = iNewsService.getHomeNewsModelList();
        req.setAttribute("newsModelList",newsModelList);
        //滑动房间图片集合获取
        IRoomService iRoomService = new RoomServiceImpl();
        List<RoomModel> roomModelList = iRoomService.getRoomModelList();
        req.setAttribute("roomModelList",roomModelList);
        //middle1vsp三张图集合元素获取
        List<RoomModel> homeRoomModelList = iRoomService.getThree();
        req.setAttribute("homeRoomModelList",homeRoomModelList);
        //服务类型集合获取
        IServiceItemsService iServiceItemsService = new ServiceItemsServiceImpl();
        List<ServiceItemsModel> serviceItemsModelList = iServiceItemsService.getServiceItemsModel();
        req.setAttribute("serviceItemsModelList",serviceItemsModelList);
        //导航元素获取
        INavService iNavService = new NavServiceImpl();
        List<NavModel> navModelList = iNavService.getNavModelListFromIo();
        req.setAttribute("navModelList",navModelList);

        req.getRequestDispatcher("/jsp/home.jsp").forward(req,resp);
    }
}
